package com.subsequent.controller;

import com.github.pagehelper.PageInfo;
import com.subsequent.dto.AssessQueryDTO;
import com.subsequent.service.AssessService;
import com.subsequent.utils.Result;
import com.subsequent.vo.AssessVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/assess")
public class AssessController {
    @Autowired
    private AssessService assessService;

    /**
     * 获取所有评估列表
     * @param assessQueryDTO
     * @return
     */
    @RequestMapping("/page")
    public Result page(@RequestBody AssessQueryDTO assessQueryDTO) {
        PageInfo<AssessVO> assessList = assessService.getAssessList(assessQueryDTO);
        return Result.success(assessList);
    }

    /**
     * 根据评估id获取评估列表
     * @param id
     * @return
     */
    @RequestMapping("/getByAssess")
    public Result getByAssess(Integer id){
        List<AssessVO> byAssess = assessService.getByAssess(id);
        return Result.success(byAssess);
    }

    /**
     * 修改评估状态
     * @param assessVO
     * @return
     */
    @RequestMapping("/updateStatus")
    public Result updateStatus(@RequestBody AssessVO assessVO){
        int i = assessService.updateStatus(assessVO);
        return Result.success(i);
    }
}
